using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class IpOverheadMap : EntityTypeConfiguration<IpOverhead>
    {
        public IpOverheadMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.INVNO)
                .IsRequired()
                .HasMaxLength(7);

            this.Property(t => t.DESC)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.File_Primary_Key)
                .HasMaxLength(10);

            this.Property(t => t.OVendid)
                .HasMaxLength(6);

            this.Property(t => t.Reference)
                .HasMaxLength(8);

            // Table & Column Mappings
            this.ToTable("IpOverheads");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.INVNO).HasColumnName("INVNO");
            this.Property(t => t.DATE).HasColumnName("DATE");
            this.Property(t => t.CURRENCY).HasColumnName("CURRENCY");
            this.Property(t => t.DESC).HasColumnName("DESC");
            this.Property(t => t.VALUE).HasColumnName("VALUE");
            this.Property(t => t.VALUEIPCURR).HasColumnName("VALUEIPCURR");
            this.Property(t => t.File_Primary_Key).HasColumnName("File Primary Key");
            this.Property(t => t.InternalExternal).HasColumnName("InternalExternal");
            this.Property(t => t.OVendid).HasColumnName("OVendid");
            this.Property(t => t.Reference).HasColumnName("Reference");
            this.Property(t => t.IPOV_Routine).HasColumnName("IPOV_Routine");
            this.Property(t => t.Ovh_Perc).HasColumnName("Ovh_Perc");

            // Relationships
            this.HasRequired(t => t.currency1)
                .WithMany(t => t.IpOverheads)
                .HasForeignKey(d => d.CURRENCY);

        }
    }
}
